package sso.server.listener;

import sso.server.utils.GlobalSessionUtil;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class GlobalSessionListener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        HttpSession httpSession = se.getSession();
        httpSession.setMaxInactiveInterval(3*60*60);//过期时间暂定3小时
        GlobalSessionUtil.addSession(se.getSession().getId(),se.getSession());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        GlobalSessionUtil.delSession(se.getSession().getId());
    }
}
